package com.bosssoft.trainee.controller;

import com.bosssoft.trainee.common.annotation.Description;
import com.bosssoft.trainee.mbg.po.Department;
import com.bosssoft.trainee.mbg.result.CommonResult;
import com.bosssoft.trainee.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: wuxin
 * @Project: rbac-SpringCloud
 * @Date: 2022/7/19
 * @Description:
 */
@RestController
@RequestMapping("/dep")
public class DepartmentController {
    @Autowired
    DepartmentService departmentService;

    @Description("获取部门列表")
    @GetMapping("/getDep")
    public CommonResult<Department[]> getDep(){
        List<Department> list = departmentService.getList();
        return CommonResult.success(list.toArray(list.toArray(new Department[0])));
    }

    @Description("根据id删除部门")
    @GetMapping("/deleteById")
    public CommonResult<Integer> deleteById(@RequestParam("id")Integer id){
        return CommonResult.success(departmentService.deleteById(id));
    }
}
